<?
	/**
	 * UCConfInvite.php
	 * 邀请逻辑配置文件
	 *
	 * Copyright (c) 2010 snda.com - Web Development Center
	 * @author: Gu Shougang <gushougang@snda.com>
	 */
	
	define('UC_INVITE_DB_PREFIX', 'd_invite_');
	define('UC_INVITE_TB_PREFIX', 't_invite_');
	
	include_once(dirname(__FILE__) . '/../UCConfMacro.php');
	
	/**
	 * 计算邀请相关逻辑涉及的数据库配置
	 * @param string $type 表名
	 * @param string $search_key 分库、表依据的字段
	 * @return array
	 */
	function invite2dbconfig($type, $search_key)
	{
		switch($type)
		{
			case 'request':
				if( defined('__UC_ENV') && __UC_ENV == 'DEV')
				{
					$host = '10.129.128.14';
					$port = 3306;
					$username = 'root';
					$password = '123qwe';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				else if( defined('__UC_ENV') && __UC_ENV == 'TEST')
				{
					$host = '10.10.85.4';
					$port = 8066;
					$username = 'ucdbuser';
					$password = 'sdf2w@!w';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				else
				{
					$host = '10.150.9.5';
					$port = 8066;
					$username = 'ucdbuser';
					$password = '(qnO-ps:Oi^0F0';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				
				return array(
					'driver' => 'mysql',
					'host' => $host,
					'port' => $port,
					'username' => $username,
					'password' => $password,
					'database' => $database,
					'table' => $table,
				);
			case 'friendexternaccount':
				if( defined('__UC_ENV') && __UC_ENV == 'DEV')
				{
					$host = '10.129.128.14';
					$port = 3306;
					$username = 'root';
					$password = '123qwe';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				else if( defined('__UC_ENV') && __UC_ENV == 'TEST')
				{
					$host = '10.10.85.4';
					$port = 8066;
					$username = 'ucdbuser';
					$password = 'sdf2w@!w';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				else
				{
					$host = '10.150.9.5';
					$port = 8066;
					$username = 'ucdbuser';
					$password = '(qnO-ps:Oi^0F0';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				
				return array(
					'driver' => 'mysql',
					'host' => $host,
					'port' => $port,
					'username' => $username,
					'password' => $password,
					'database' => $database,
					'table' => $table,
				);
			case 'mailqueue':
				if( defined('__UC_ENV') && __UC_ENV == 'DEV')
				{
					$host = '10.129.128.14';
					$port = 3306;
					$username = 'root';
					$password = '123qwe';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				else if( defined('__UC_ENV') && __UC_ENV == 'TEST')
				{
					$host = '10.10.85.4';
					$port = 8066;
					$username = 'ucdbuser';
					$password = 'sdf2w@!w';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				else
				{
					$host = '10.150.9.5';
					$port = 8066;
					$username = 'ucdbuser';
					$password = '(qnO-ps:Oi^0F0';
					$database = UC_INVITE_DB_PREFIX . $type;
					$table = UC_INVITE_TB_PREFIX . $type;
				}
				
				return array(
					'driver' => 'mysql',
					'host' => $host,
					'port' => $port,
					'username' => $username,
					'password' => $password,
					'database' => $database,
					'table' => $table,
				);
			default:
				return array();
		}
	}
	
	function get_invite_tt_config($type, $search_key)
	{
		$host = '';
		$port = strtoupper($type);
	
		switch($type)
		{
			case 'ticketId_CallBackUrl':
			case 'ticketId_SDOAccount':
			case 'SDOAccount_ticketId':
			case 'SDOAccount_ExternAccount':
			case 'externAccount_SDOAccount':
				return array(
					'db_driver' => 'tt',
					'db_host' => $host,
					'db_port' => $port,
					'tb_name' => md5(UC_INVITE_TB_PREFIX . $type . md5($search_key)),
				);
			default:
				return array();
		}
	}
	
	/**
	 * Invite URL
	 */
	define('UC_INVITE_URL', UC_CONF_UC_DOMAIN . '/invite/receipt?');
	define('UC_INVITE_CLOSE', 0);
	define('UC_INVITE_OPEN', 1);
	
	/**
	 * Invite 加密Key
	 */
	define('UC_INVITE_ENCRYPTION_KEY', 'hvtipvhbohmwftifmyjmh');
	
	/**
	 * 全站统一登录/注册地址
	 */
	//define('SITE_LOGIN_URL', 'http://www.sdo.com/loginPT.asp?service=');
	define('SITE_LOGIN_URL', 'http://www.sdo.com/IframeLogin.asp?');
	define('SITE_LOGIN_CSS', UC_CONF_UC_DOMAIN . '/html/style/IframeLogin.css');
	define('UC_APPID', 219);
	//define('SITE_LOGIN_URL', 'http://dev.pt.sdo.com/IframeLogin.asp?');
	
	//if( defined('__UC_ENV') && __UC_ENV == 'DEV')
	//{
	//	define('SITE_REG_URL', 'http://dev.pt.sdo.com/PTReg-New/default.aspx?cssId=uc&CUSTOM_REG_SUCC_JUMP_ID=EWallet&CUSTOM_REG_SUCC_URL=');
	//}
	//else
	//{
		define('SITE_REG_URL', 'http://register.sdo.com/register.asp?cssId=uc&from=' .UC_APPID. '&zone=web&CUSTOM_REG_SUCC_URL=');
	//}
	
	
	/**
	 * 错误代码
	 */
	define('UC_QQ_PARAMS_ERROR', '01');
	define('UC_MSN_PARAMS_ERROR', '02');
	define('UC_EMAIL_PARAMS_ERROR', '03');
	define('UC_SDO_USERID_ERROR', '04');
	define('UC_DO_NOT_SUPPORT_EMAIL', '05');
	define('UC_ERROR', '98');
	define('UC_OK', '99');
	
	/**
	 * 邀请统计监控代码
	 */
	define('TOTAL_SUCC_INVITE', '29|34|35|43');			//邀请成功总人数
	define('TOTAL_SUCC_SEMAIL', '29|34|35|44');			//发送邮件邀请函成功总人数
	define('TOTAL_SUCC_LINK', '29|34|35|45');			//链接邀请成功总人数
	define('TOTAL_SUCC_MSN', '29|34|35|46');			//MSN导入邀请成功总人数
	define('TOTAL_SUCC_EMAIL', '29|34|35|47');			//Email导入邀请成功总人数
	define('TOTAL_MAIL_INVITE', '29|34|35|48');			//总发出邮件数
	define('TOTAL_MAIL_SEMAIL', '29|34|35|49');			//通过发送邮件邀请函发出的邮件数
	define('TOTAL_MAIL_MSN', '29|34|35|50');			//通过MSN导入发出邮件数
	define('TOTAL_MAIL_EMAIL', '29|34|35|51');			//通过Email导入发出邮件数
	define('TOTAL_SUCC_APP_LINK', '29|34|35|52');			//APP链接邀请成功总人数
	define('TOTAL_SUCC_APP_SEMAIL', '29|34|35|53');			//APP普通Email邀请成功总人数
	define('TOTAL_OPEN_INVITE_USER', '');				//每天打开邀请好友页面的总人数
	
	/**
	 * 邀请状态定义
	 */
	define('INVITE_INIT', 0);		//新建邀请
	define('INVITE_SEND_EMAIL', 1);	//已发送邀请邮件
	define('INVITE_OVER', 4);		//已经结束的邀请
		
	/**
	 * 邮件发送数量限制
	 */
	define('SEMAIL_SEND_LIMIT', 200);
	
	/**
	 * 邀请类型定义
	 */
	//type = 1;	//MSN好友列表
	//type = 2;	//EMAIL通讯录
	//type = 3;	//普通EMAIL邀请
	//type = 4;	//APP普通EMAIL邀请
	//type = 5;	//普通链接邀请
	//type = 6;	//APP链接邀请
	define('INVITE_TYPE_MSN', 1);
	define('INVITE_TYPE_EMAIL', 2);
	define('INVITE_TYPE_SEMAIL', 3);
	define('INVITE_TYPE_APP_SEMAIL', 4);
	define('INVITE_TYPE_LINK', 5);
	define('INVITE_TYPE_APP_LINK', 6);
?>